#include "stdafx.h"
#include "cRechthoek.h"

cRechthoek rh;

void cRechthoek::draw(Int pos, Int size, Str caption) {
	Flt leftX = ((pos / steps) * 2.1) - 0.9;
	Flt rightX = leftX + ((size / steps) * 2.1);

	D.rect(color, leftX, vPos, rightX, vPos + 0.05);
	D.rectL(BLACK, leftX, vPos, rightX, vPos + 0.05);

	// now draw text if needed
	if (caption.length()) {
		TextDS tds;
		tds.color = BLACK;
		tds.align.set(1, 0);
		tds.shade = 0;
		tds.shadow = 0;
		tds.scale *= 0.4;
		
		D.text(tds, leftX + 0.01, vPos + 0.025, caption);
	}
}

void cRechthoek::setLine(Int l) {
	line = l;
	// max 20 lines on a screen, gives each line about 0.1 of spacing
	vPos = 2.0 - (line / 17.0);
	vPos -= 1.0;
}

void cRechthoek::setSteps(Int s) {
	steps = s;
}

void cRechthoek::setColor(Color c) {
	color = c;
}

void cRechthoek::drawCaption(Str caption) {
	TextDS tds;
	tds.color = BLACK;
	tds.align.set(-1, 0);
	tds.shade = 0;
	tds.shadow = 0;
	tds.scale *= 0.6;
	
	D.text(tds, -1, vPos + 0.02, caption);
}
	

cRechthoek::cRechthoek(void){
	line = 1;
	steps = 100.0;
	color = GREY_LIGHT;

}

cRechthoek::~cRechthoek(void){
}
